PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Exists

Exists is an application command that determines whether the object specified by a reference exists.

SYNTAX
referenceToObject exists exists referenceToObject
PARAMETER
referenceToObject
A reference to the object or objects to find. Class: Reference
RESULT

The result is true if all of the objects referred to by referenceToObject exist, false if one or more of the objects referred to by referenceToObject do not exist. Class: Boolean

EXAMPLES

The following example checks whether a folder exists before attempting to count the files in the folder.

tell application "Finder"
    if folder "Apple Extras" of startup disk exists then
        count files in folder "Apple Extras" of startup disk
    end if
end tell

The next example deletes the first paragraph from a report document, if the paragraph exists.

tell document "My Report" of application "AppleWorks"
    if paragraph 1 of text body exists then
        delete paragraph 1 of text body
    end if
end tell

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)